import ConfigurationConstant from "@ohos.app.ability.ConfigurationConstant";
import window from "@ohos.window";
class WindowManager {
    constructor() {
        this.windowStage = null;
    }
    async getWindowStage() {
        if (this.windowStage) {
            return this.windowStage;
        }
        else {
            return await window.getLastWindow(getContext());
        }
    }
    initThemeSetting() {
        const d35 = getContext()
            .getApplicationContext();
        d35.on('environment', {
            onConfigurationUpdated: (h35) => {
                AppStorage.set('colorMode', h35.colorMode);
                if (h35.colorMode === ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT) {
                    this.settingStatusBarBlack();
                }
                if (h35.colorMode === ConfigurationConstant.ColorMode.COLOR_MODE_DARK) {
                    this.settingStatusBarWhite();
                }
                if (h35.colorMode === ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET) {
                }
            },
            onMemoryLevel: (g35) => {
            }
        });
        const e35 = AppStorage.get('initColorMode');
        PersistentStorage.persistProp('colorMode', e35);
        const f35 = AppStorage.get('colorMode');
        d35.setColorMode(f35);
    }
    settingStatusBarWhite() {
        this.settingStatusBar({ statusBarContentColor: '#FFFFFF' });
    }
    settingStatusBarBlack() {
        this.settingStatusBar({ statusBarContentColor: '#000000' });
    }
    settingStatusBar(a35) {
        this.getWindowStage()
            .then((c35) => {
            c35.setWindowSystemBarProperties(a35);
        });
    }
    enableFullScreen() {
        this.getWindowStage()
            .then((x34) => {
            x34.setWindowLayoutFullScreen(true);
            const y34 = x34.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM);
            AppStorage.setOrCreate('topHeight', px2vp(y34.topRect.height));
            const z34 = x34.getWindowAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR);
            AppStorage.setOrCreate('bottomHeight', px2vp(z34.bottomRect.height));
        });
    }
    disableFullScreen() {
        this.getWindowStage()
            .then((v34) => {
            v34.setWindowLayoutFullScreen(false);
            AppStorage.setOrCreate('topHeight', 0);
            AppStorage.setOrCreate('bottomHeight', 0);
        });
    }
}
export const windowManager = new WindowManager();
